﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace InpatientManagementSystem
{
    public partial class Form2 : Form
    {
        MySqlConnection myConnection = new MySqlConnection("server=localhost;user=root;password=786452as;database=zhuyuan;port=3306;charset=utf8");
        public Form2()
        {
            InitializeComponent();
        }

        public string getInsp()
        {
            if (comboBox1.SelectedIndex == -1)
            {
                return "";
            }
            else
            {
                return comboBox1.SelectedItem.ToString();
            }
        }
        public string getDetail()
        {
            if (comboBox2.SelectedIndex == -1)
            {
                return "";
            }
            else
            {
                return comboBox2.SelectedItem.ToString();
            }
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            myConnection.Open();
            string query = "select * from inspect_project";
            MySqlCommand myCommand = new MySqlCommand(query, myConnection);
            MySqlDataReader myReader = myCommand.ExecuteReader();
            try
            {
                while (myReader.Read())
                {
                    comboBox1.Items.Add(myReader.GetString(1));
                }
            }
            finally
            {
                myReader.Close();
                myConnection.Close();
            }
            comboBox2.Items.Add("一次");
            comboBox2.Items.Add("一周一次共四次");
            comboBox2.Items.Add("一月一次共两次");
            comboBox2.Items.Add("每天一次");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(comboBox1.SelectedIndex == -1 || comboBox2.SelectedIndex == -1)
            {
                MessageBox.Show("请选择好再添加");
            }
            else
            {
                Close();
            }
        }
    }
}
